package com.tbit.uqbike.client.constant.enums;

/**
 * 人脸识别频率校验枚举
 *  0:短时间失败上限 1：短时间使用上限 2：今日使用上限
 * @author <a href="mailto:liu.haoxiang@tbit.com.cn">BUGXiang</a>
 * @since 2024/6/17
 */
public enum FaceTimeCheckEnum {

    SHORT_TERM_FAILURE(0, "短时间内人脸校验失败次数过多，为了确保您的账户安全，请%s分钟后再尝试。如有疑问，请联系客服了解详情"),
    SHORT_TERM(1, "短时间内人脸校验过于频繁，为了确保您的账户安全，请%s分钟后再尝试。如有疑问，请联系客服了解详情"),
    TODAY_TOTAL(2, "人脸校验已超过今日上限，为了确保您的账户安全，请%s小时后再尝试。如有疑问，请联系客服了解详情");


    FaceTimeCheckEnum(Integer lockType, String desc) {
        this.lockType = lockType;
        this.desc = desc;
    }

    private Integer lockType;

    private String desc;

    public Integer getLockType() {
        return lockType;
    }

    public String getDesc(Integer time) {
        if (this.lockType == 2) {
            time = time / 60;
        }
        return String.format(desc, time);
    }

    public static String getDescByLockType(Integer lockType) {
        for (FaceTimeCheckEnum e : values()) {
            if (e.lockType.equals(lockType)) {
                return e.desc;
            }
        }
        return "";
    }
}
